package com.uzai.console.web.mini;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.uzai.console.annotation.SystemLogType;
import com.uzai.console.dto.BaseDto;
import com.uzai.console.dto.mini.minigoods.*;
import com.uzai.console.enums.OperationTypeEnum;
import com.uzai.console.enums.SystemModelEnum;
import com.uzai.console.service.mini.MiniGoodsService;
import com.uzai.console.vo.mini.minigoods.MiniGoodsVo;
import com.uzai.console.web.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 小程序团购商品管理
 * @author liuqi
 * @date 2021年08月16日 15:11
 */
@Api(value = "团购商品",tags = "微信小程序|团购商品")
@ApiSort(7)
@RestController
public class MiniGoodsController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(MiniGoodsController.class);

    @Autowired
    private MiniGoodsService miniGoodsService;

    @ApiOperation(value = "分页查询小程序团购商品列表", notes = "分页查询小程序团购商品列表", response = MiniGoodsVo.class)
    @ApiOperationSupport(order = 1)
    @PostMapping("/miniGoods/findByPage")
    public Object fingMiniGoodsByPage(@RequestBody MiniGoodsQuery miniGoodsQuery){
        return miniGoodsService.findMiniGoodsByPage(miniGoodsQuery);
    }

    @ApiOperation(value = "查询小程序团购商品详情", notes = "查询小程序团购商品详情", response = MiniGoodsVo.class)
    @ApiOperationSupport(order = 2)
    @PostMapping("/miniGoods/findById")
    public Object findCmsMerTbGoodsList(@RequestBody MiniGoodsIdDto miniGoodsIdDto){
        return miniGoodsService.findMiniGoodsById(miniGoodsIdDto);
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.ADD)
    @ApiOperation(value = "添加小程序团购商品", notes = "添加小程序团购商品")
    @ApiOperationSupport(order = 3)
    @PostMapping("/miniGoods/add")
    public Object addMiniGoods(@RequestBody MiniGoodsDto miniGoodsDto){
        miniGoodsService.addMiniGoods(miniGoodsDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改小程序团购商品信息", notes = "修改小程序团购商品信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/miniGoods/update")
    public Object updateMiniGoods(@RequestBody MiniGoodsDto miniGoodsDto){
        miniGoodsService.updateMiniGoods(miniGoodsDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.DELETE)
    @ApiOperation(value = "删除小程序团购商品信息", notes = "删除小程序团购商品信息")
    @ApiOperationSupport(order = 4)
    @PostMapping("/miniGoods/delete")
    public Object deleteMiniGoods(@RequestBody MiniGoodsIdDto miniGoodsIdDto){
        miniGoodsService.deleteMiniGoods(miniGoodsIdDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改小程序团购商品库存量", notes = "修改小程序团购商品库存量")
    @ApiOperationSupport(order = 5)
    @PostMapping("/miniGoods/updateStoreCount")
    public Object updateMiniGoodsStatus(@RequestBody MiniGoodsStoreCountDto miniGoodsStoreCountDto){
        miniGoodsService.updateMiniGoodsStoreCount(miniGoodsStoreCountDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "下架上线小程序团购商品", notes = "下架上线小程序团购商品")
    @ApiOperationSupport(order = 6)
    @PostMapping("/miniGoods/updateStatus")
    public Object updateMiniGoodsStatus(@RequestBody MiniGoodsStatusDto miniGoodsStatusDto){
        miniGoodsService.updateMiniGoodsStatus(miniGoodsStatusDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "是否显示小程序团购商品", notes = "是否显示小程序团购商品")
    @ApiOperationSupport(order = 7)
    @PostMapping("/miniGoods/updateShowStatus")
    public Object updateMiniGoodsShowStatus(@RequestBody MiniGoodsShowStatusDto miniGoodsShowStatusDto){
        miniGoodsService.updateMiniGoodsShowStatus(miniGoodsShowStatusDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "修改小程序团购商品页面排序", notes = "修改小程序团购商品页面排序")
    @ApiOperationSupport(order = 8)
    @PostMapping("/miniGoods/updatePageOrder")
    public Object updateMiniGoodsPageOrder(@RequestBody MiniGoodsPageOrderDto miniGoodsPageOrderDto){
        miniGoodsService.updateMiniGoodsPageOrder(miniGoodsPageOrderDto);
        return true;
    }

    @SystemLogType(model = SystemModelEnum.MiniGoods, type = OperationTypeEnum.UPDATE)
    @ApiOperation(value = "小程序团购商品一键同步官方商品", notes = "小程序团购商品一键同步官方商品")
    @ApiOperationSupport(order = 8)
    @PostMapping("/miniGoods/useGod")
    public Object useGodMiniGoods(@RequestBody BaseDto baseDto){
        miniGoodsService.useGodMiniGoods(baseDto);
        return true;
    }

}
